{	Problem: http://codeforces.ru/problemset/problem/71/A
	Verdict: Accepted
}
var i,n:longint; t:string;
begin
readln(n);
for i:=1 to n do begin
   readln(t);
   if length(t)>10 then
       writeln(t[1],length(t)-2,t[length(t)]) else writeln(t);  
end;
end.